package com.shchekoldin.server.presenter;

public enum IssueStatus {

    // -------------------------------------------------------
    // VALUES
    // -------------------------------------------------------

    OPEN(1),

    IN_PROGRESS(3),

    REOPENED(4),

    RESOLVED(5),

    CLOSED(6),

    CODE_REVIEW_IN_PROGRESS(10000),

    REOPENED_AFTER_CODE_REVIEW(10001),

    NEED_REVIEW(10002);

    // -------------------------------------------------------
    // FIELDS
    // -------------------------------------------------------
    
    private int jiraCode;

    // -------------------------------------------------------
    // LOGIC
    // -------------------------------------------------------

    private IssueStatus(int jiraCode) {
        this.jiraCode = jiraCode;
    }

    //
    // API
    //

    public static IssueStatus parse(String value) {
        int intValue = Integer.parseInt(value);

        for (IssueStatus issueStatus : IssueStatus.values()) {
            if (intValue == issueStatus.jiraCode) {
                return issueStatus;
            }
        }

        return null;
    }

}
